package cracker.data;

import java.io.Serializable;
import java.util.Map;

import cracker.client.Address;

/**
 * 数据包
 * @author ljh_2018
 *
 */
public class AbstactDataPack implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Address source;

	private Address target;

	private Map<String,Object> body;

	private long timeout;

	private long start;

	private long end;


	public Map<String, Object> getBody() {
		return body;
	}


	public void setBody(Map<String, Object> body) {
		this.body = body;
	}


	public long getTimeout() {
		return timeout;
	}


	public void setTimeout(long timeout) {
		this.timeout = timeout;
	}


	public long getStart() {
		return start;
	}


	public void setStart(long start) {
		this.start = start;
	}


	public long getEnd() {
		return end;
	}


	public void setEnd(long end) {
		this.end = end;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("[source:"+this.source+" target:"+this.target+" data: \n\t{");
		for(String key:body.keySet()) {
			sb.append(key+":"+body.get(key)+"\n\t");
		}
		sb.append("} ");
		sb.append("time:"+(end-start)+"ms");
		sb.append("]");
		return sb.toString();
	}
}
